<!DOCTYPE HTML PUBLIC "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-PT">
	<head>
		<title>Javascript Overload</title>
		<script type="text/javascript">


			Function.prototype.overload = function(){
				if(!this.__OVERLOAD__)this.__OVERLOAD__ = [];
				
				var h = Array.prototype.pop.call(arguments);
					h.args = arguments;

					this.overloadtest = function(args){
						for(var a=0,z=true;this.__OVERLOAD__[a];a++){
							for(var b=0,s;s=this.__OVERLOAD__[a].args[b];b++){
								if(s === args[b].constructor) z=false;
							}
							if(z) return this.__OVERLOAD__[a];
						}
					}
					console.log(this, this.toString())
					return this.__OVERLOAD__.push(h);
			}
			

			function Teste(a,b,c){
				console.warn(a,b,c);
			}
			
			Teste.overload(Number,String,Object,function(a,b,c){
				console.info(a,b,c);
			})
			Teste.overload(Number,function(a){
				console.log(a);
			})
			
			
		</script>
	</head>
	<body>
		<h1>Javascript Function Overload</h1>
	</body>
</html>